package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhStoreCategory;
import com.ruoyi.zsyh.service.IZsyhStoreCategoryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修店服务类目Controller
 * 
 * @author yuexl
 * @date 2022-02-22
 */
@Controller
@RequestMapping("/zsyh/storeCategory")
public class ZsyhStoreCategoryController extends BaseController
{
    private String prefix = "zsyh/storeCategory";

    @Autowired
    private IZsyhStoreCategoryService zsyhStoreCategoryService;

    @RequiresPermissions("zsyh:storeCategory:view")
    @GetMapping("/viewStoreCategory")
    public String viewStoreCategory(String storeId,ModelMap mmap)
    {
        mmap.put("storeId",storeId);
        return prefix + "/storeCategory";
    }

    @RequiresPermissions("zsyh:storeCategory:view")
    @GetMapping()
    public String storeCategory()
    {
        return prefix + "/storeCategory";
    }

    /**
     * 查询维修店服务类目列表
     */
    @RequiresPermissions("zsyh:storeCategory:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhStoreCategory zsyhStoreCategory)
    {
        startPage();
        List<ZsyhStoreCategory> list = zsyhStoreCategoryService.selectZsyhStoreCategoryList(zsyhStoreCategory);
        return getDataTable(list);
    }

    /**
     * 导出维修店服务类目列表
     */
    @RequiresPermissions("zsyh:storeCategory:export")
    @Log(title = "维修店服务类目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhStoreCategory zsyhStoreCategory)
    {
        List<ZsyhStoreCategory> list = zsyhStoreCategoryService.selectZsyhStoreCategoryList(zsyhStoreCategory);
        ExcelUtil<ZsyhStoreCategory> util = new ExcelUtil<ZsyhStoreCategory>(ZsyhStoreCategory.class);
        return util.exportExcel(list, "维修店服务类目数据");
    }

    /**
     * 新增维修店服务类目
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存维修店服务类目
     */
    @RequiresPermissions("zsyh:storeCategory:add")
    @Log(title = "维修店服务类目", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhStoreCategory zsyhStoreCategory)
    {
        return toAjax(zsyhStoreCategoryService.insertZsyhStoreCategory(zsyhStoreCategory));
    }

    /**
     * 修改维修店服务类目
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhStoreCategory zsyhStoreCategory = zsyhStoreCategoryService.selectZsyhStoreCategoryById(id);
        mmap.put("zsyhStoreCategory", zsyhStoreCategory);
        return prefix + "/edit";
    }

    /**
     * 修改保存维修店服务类目
     */
    @RequiresPermissions("zsyh:storeCategory:edit")
    @Log(title = "维修店服务类目", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhStoreCategory zsyhStoreCategory)
    {
        return toAjax(zsyhStoreCategoryService.updateZsyhStoreCategory(zsyhStoreCategory));
    }

    /**
     * 删除维修店服务类目
     */
    @RequiresPermissions("zsyh:storeCategory:remove")
    @Log(title = "维修店服务类目", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhStoreCategoryService.deleteZsyhStoreCategoryByIds(ids));
    }
}
